package ink.lovejinhu.swardToOffer;

public class Offer_057 {
    public int[] twoSum(int[] nums, int target) {
        int[] res = new int[2];
        for (int i = 0, j = nums.length - 1; i < j; ) {
            if (nums[i] + nums[j] == target) {
                res[0] = nums[i];
                res[1] = nums[j];
                break;
            } else if (nums[i] + nums[j] > target) {
                j--;
            } else {
                i++;
            }
        }
        return res;
    }
}
